package com.dm.cloud.images.mode;

import com.github.dockerjava.api.command.InspectVolumeResponse;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.Map;

@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description ="Docker网络模型")
@Data
public class VolumeDetail {

    @Schema(description = "数据卷名称")
    private String name;

    @Schema(description = "数据卷标签")
    private Map<String, String> labels;

    @Schema(description = "驱动类型")
    private String driver;

    @Schema(description = "挂载点")
    private String mountpoint;

    @Schema(description = "相关配置")
    private Map<String, String> options;

    @Schema(description = "自定义节点ID")
    private String nodeId;

    @Schema(description = "自定义节点名称")
    private String nodeName;

    @Schema(description = "自定义节点IP")
    private String nodeHost;

    public static VolumeDetail buildByInspect(InspectVolumeResponse inspect,String nodeId,String nodeName,String nodeHost) {
        VolumeDetail volume = VolumeDetail
                .builder()
                .driver(inspect.getDriver())
                .labels(inspect.getLabels())
                .mountpoint(inspect.getMountpoint())
                .name(inspect.getName())
                .options(inspect.getOptions())
                .nodeId(nodeId)
                .nodeName(nodeName)
                .nodeHost(nodeHost)
                .build();
        return volume;
    }
}
